package com.client.service;

import com.client.pojo.Product;
import com.client.service.Impl.ProductServiceFallBack;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@FeignClient(value = "product-service",path = "/products",fallback = ProductServiceFallBack.class)
public interface ProductService {

    @PostMapping
    public ResponseEntity<Product> addProduct(@RequestBody Product product);

    // 更新商品信息
    @PutMapping
    public ResponseEntity<Product> updateProduct(@RequestBody Product product);

    // 删除商品
    @DeleteMapping("/{productId}")
    public ResponseEntity<Void> deleteProduct(@PathVariable("productId") String productId);

    // 根据商品ID获取商品信息
    @GetMapping("/{productId}")
    public ResponseEntity<Product> getProductById(@PathVariable("productId") String productId);

    // 获取所有商品列表
    @GetMapping
    public ResponseEntity<List<Product>> listAllProducts();

    // 根据分类获取商品列表
    @GetMapping("/category/{categoryId}")
    public ResponseEntity<List<Product>> listProductsByCategory(@PathVariable("categoryId") String categoryId);

    // 商品上架
    @PutMapping("/{productId}/on-shelf")
    public ResponseEntity<Void> onShelf(@PathVariable("productId") String productId);

    // 商品下架
    @PutMapping("/{productId}/off-shelf")
    public ResponseEntity<Void> offShelf(@PathVariable("productId") String productId);

}
